@extends('layouts.app')

@section('title', isset($category) ? $category->name : '话题列表')

@section('content')

    <div class="row mb-5">
        <div class="col-lg-9 col-md-9 topic-list">

            @if (isset($category))
                <div class="alert alert-info" role="alert">
                    {{ $category->name }} ：{{ $category->description }}
                </div>
            @elseif (isset($tag))
                <div class="alert alert-info" role="alert">
                    标签 ：{{ $tag->name }}
                </div>
            @elseif ($keywords = purifier_search_keywords( request('keywords')))
                <div class="alert alert-info" role="alert">
                    搜索 ：{{ $keywords }}
                </div>
            @endif

            <div class="card ">

                <div class="card-header bg-transparent">
                    <ul class="nav nav-pills">
                        <li class="nav-item">
                            <a class="nav-link {{ active_class(!if_query('order','recent')) }}"
                               href="{{ request()->url() }}?order=default{{ isset($keywords)?'&keywords='.$keywords:'' }}">
                                最后回复
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ active_class(if_query('order','recent')) }}"
                               href="{{ request()->url() }}?order=recent{{ isset($keywords)?'&keywords='.$keywords:'' }}">
                                最新发布
                            </a>
                        </li>

                    </ul>
                </div>

                <div class="card-body">
                    {{-- 话题列表 --}}
                    @include('topics._topic_list', ['topics' => $topics])
                    {{-- 分页 --}}
                    <div class="mt-5">
                        {!! $topics->appends(Request::except('page'))->render() !!}
                    </div>
                </div>
            </div>
        </div>

        <div class="col-lg-3 col-md-3 sidebar">
            <div class="card ">
                <div class="card-body">
                    <a href="{{ route('topics.create') . (request('category.id')?'?category_id='.request('category.id'):'')}}"
                       class="btn btn-success btn-block" aria-label="Left Align">
                        <i class="fas fa-pencil-alt mr-2"></i> 新建帖子
                    </a>
                </div>
            </div>

            @include('topics._sidebar')
        </div>
    </div>

@endsection
